Feat/escrow expiration handler#80
Merged
Cedarich merged 3 commits intoStayLitCodes:mainfrom Feb 20, 2026
Merged
Conversation
Contributor
Author
|
@Cedarich fixed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a robust background job processing system that automatically handles expired escrows, preventing funds from being locked indefinitely and ensuring proper dispute resolution workflows. The implementation addresses the critical need for automated escrow lifecycle management.
🎯 Problem Solved
expiresAtfield had no enforcement mechanism🚀 Features Implemented
⏰ Scheduled Jobs
@Cron(CronExpression.EVERY_HOUR))@Cron(CronExpression.EVERY_DAY_AT_9AM))🔄 Automated Workflows
Expired PENDING Escrows
AUTO_CANCELLEDevent with reasonEXPIRED_PENDINGESCROW_AUTO_CANCELLEDnotifications to all partiesExpired ACTIVE Escrows
AUTO_ESCALATED_TO_DISPUTEevent with reasonEXPIRED_ACTIVEESCROW_ESCALATED_TO_DISPUTEnotificationsExpiration Warnings
expirationNotifiedAttimestampESCROW_EXPIRING_SOONwith hours remaining🛡️ Safety & Reliability
Idempotency
expirationNotifiedAtprevents duplicate warningsError Handling
Audit Trail
EscrowEvententries🎛️ Admin Controls
Manual Processing Endpoints
Access Control
AuthGuard+AdminGuard🔔 Notification System
Webhook Integration
Notification Types
ESCROW_AUTO_CANCELLED- Automatic cancellationESCROW_ESCALATED_TO_DISPUTE- Dispute escalationESCROW_EXPIRING_SOON- 24-hour warning📊 Database Changes
Escrow Entity Updates
Event Types Added
AUTO_CANCELLED- System-initiated cancellationAUTO_ESCALATED_TO_DISPUTE- System-initiated disputeEXPIRATION_WARNING_SENT- Warning notification🧪 Testing Coverage
E2E Test Scenarios
Test Features
🏗 Architecture
Service Layer
Module Integration
📈 Performance Considerations
Efficient Queries
expiresAtandstatusfieldsResource Management
🔧 Configuration
Environment Variables
Grace Periods
🚀 Deployment Notes
Database Migration
Multi-Instance Support
📋 Future Enhancements
Planned Features
Monitoring Integration
🔒 Security Considerations
Access Control
Data Privacy
📚 Documentation
API Endpoints
Operations Guide
✅ Validation Checklist
🎉 Impact
This implementation significantly improves the reliability and user experience of the escrow system by:
The system is now production-ready with robust error handling, comprehensive testing, and scalable architecture.
closes #66